home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / util / pack / xpk_Source.lha / xpk_Source / xpkmaster / xbuf.c < prev    next >
C/C++ Source or Header  |  1996-11-26  |  1KB  |  58 lines

  1. #ifndef XPKMASTER_XBUF_C
  2. #define XPKMASTER_XBUF_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        xbuf.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: xbuf.c 1.0 (09.10.96)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Xpk buffer handling
  12.  
  13.  1.0   09.10.96 : first real version
  14. */
  15.  
  16. #include <pragma/exec_lib.h>
  17. #include <exec/memory.h>
  18. #include <exec/libraries.h>
  19. #include <dos/dos.h>
  20. #include "xpkmaster.h"
  21.  
  22. /************************* alloc and init xbuf ***************************/
  23.  
  24. struct XpkBuffer *initxbuf(void)
  25. {
  26.   struct XpkBuffer *xbuf;
  27.  
  28.   if(!(xbuf = (struct XpkBuffer *) AllocMem(sizeof(struct XpkBuffer),
  29.   MEMF_CLEAR)))
  30.     return 0;
  31.   /* Save the original task priority in case we change it during an
  32.      operation */
  33.  
  34.   xbuf->xb_Priority = FindTask(0L)->tc_Node.ln_Pri;
  35.  
  36.   xbuf->xb_InLen = -1;
  37.   xbuf->xb_Prog.xp_FileName = "";
  38.  
  39.   return xbuf;
  40. }
  41.  
  42. /***************************** free bufs *******************************/
  43. LONG freebufs(struct XpkBuffer *xbuf)
  44. {                /* Free an XpkBuffer */
  45.   LONG error = xbuf->xb_Result;
  46.  
  47.   closesub(xbuf);        /* Free any open sub-library */
  48.  
  49.   if(xbuf->xb_Flags & XMF_OWNTASKPRI)
  50.     SetTaskPri(FindTask (NULL), xbuf->xb_Priority);
  51.  
  52.   FreeMem(xbuf, sizeof(struct XpkBuffer));
  53.                 /* Finally, free the handle itself */
  54.   return error;
  55. }
  56.  
  57. #endif /* XPKMASTER_XBUF_C */
  58.